
class Plugin(object):
  def __init__(self):
    self._mainFrm = None
    self._pluginMgr = None
    self._pane = None
    self._configPane = None
    self._menus = None
    self._toolbar = None

  def init(self, mainFrame, pluginManager):
    self._mainFrm = mainFrame
    self._pluginMgr = pluginManager

  def uninit(self):
    self._mainFrm = None
    self._pluginMgr = None

  def getPane(self):
    if self._pane is None:
      self._pane = self.createPane()
    return self._pane

  def createPane(self):
    return None

  def getConfigPane(self):
    if self._configPane is None:
      self._configPane = self.createConfigPane()
    return self._configPane

  def createConfigPane(self):
    return None

  def getMenu(self):
    if self._menus is None:
      self._menus = self.createMenus()
    return self._menus

  def createMenus(self):
    return None

  def getToolbar(self):
    if self._toolbar is None:
      self._toolbar = self.createToolbar()
    return self._toolbar

  def createToolbar(self):
    return None

instance = None
def getInstance():
  global instance
  if instance is None:
    instance = createInstance()
  return instance

def createInstance():
  return Plugin()

##############################################################
## test codes
if __name__ == '__main__':
  class TestPlugin(Plugin):
    def createInstance():
      return TestPlugin()

  testPlugin = getInstance()
  print type(testPlugin)
  